<?php
namespace Home\Controller;
use Think\Controller;
class ArtificialController extends Controller {
    public function artificial($sid=0,$p=1){
       //取产品分类
		$proartificial=M(proartificial);//选择数据表
		$result=$proartificial->where("pid=0")->order("o asc")->limit(0,6)->select();
		$this->assign("type_info",$result);
		

		//分页获取产品的信息
		$sid = intval($sid);    //分类id
		$p = intval($p)>0?$p:1;//当前页码
		
		$artificial = M('artificial');//选择数据表
		$pagesize = 5;#每页数量
		$offset = $pagesize*($p-1);//计算记录偏移量
		$prefix = C('DB_PREFIX');
		if($sid){
			$where = "{$prefix}artificial.sid=$sid";
		}else{
			$where = '';
		}
		$count = $artificial->where($where)->count();
		$list  = $artificial->field("{$prefix}artificial.*,{$prefix}proartificial.name")->where($where)->order("{$prefix}artificial.pid desc")->join("{$prefix}proartificial ON {$prefix}proartificial.id = {$prefix}artificial.sid")->limit($offset.','.$pagesize)->select();
		
		$page	=	new \Think\Page($count,$pagesize); 
		$page = $page->show();
        $this->assign('prolist',$list);	
        $this->assign('page',$page);
        $this->display();
    }
     public function garden($sid=0,$p=1){
     	//取产品分类
		$progarden=M(progarden);//选择数据表
		$result=$progarden->where("pid=0")->order("o asc")->limit(0,6)->select();
		$this->assign("type_info",$result);
     	

     	//分页获取产品的信息
		$sid = intval($sid);    //分类id
		$p = intval($p)>0?$p:1;//当前页码
		
		$garden = M('garden');//选择数据表
		$pagesize = 5;#每页数量
		$offset = $pagesize*($p-1);//计算记录偏移量
		$prefix = C('DB_PREFIX');
		if($sid){
			$where = "{$prefix}garden.sid=$sid";
		}else{
			$where = '';
		}
		$count = $garden->where($where)->count();
		$list  = $garden->field("{$prefix}garden.*,{$prefix}progarden.name")->where($where)->order("{$prefix}garden.pid desc")->join("{$prefix}progarden ON {$prefix}progarden.id = {$prefix}garden.sid")->limit($offset.','.$pagesize)->select();
		
		$page	=	new \Think\Page($count,$pagesize); 
		$page = $page->show();
        $this->assign('prolist',$list);	
        $this->assign('page',$page);
    $this->display();
   

     }
}